/*
 *  This file is part of LifeBudget - Copyright 2010 Clifton Eaton
 *  ------------------------------------------------------------------
 *  LifeBudget is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  LifeBudget is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with LifeBudget.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.lifebudget.app.client;

import org.lifebudget.app.client.events.AppEvents;
import org.lifebudget.app.client.mvc.controller.AppController;
import org.lifebudget.app.client.mvc.controller.CategoriesController;
import org.lifebudget.app.client.mvc.controller.OverviewController;
import org.lifebudget.app.client.mvc.controller.PaycheckCalculatorController;
import org.lifebudget.app.client.mvc.controller.TabController;
import org.lifebudget.app.client.mvc.controller.TransactionJournalController;

import com.extjs.gxt.themes.client.Slate;
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.google.gwt.core.client.EntryPoint;

/**
 * Entry point class for the LifeBudget GWT application.  
 */
public class LifeBudget implements EntryPoint {
	private static final boolean TEST_MODE = true;
	/**
	 * The message displayed to the user when the server cannot be reached or
	 * returns an error.
	 */
	private static final String SERVER_ERROR = "An error occurred while "
			+ "attempting to contact the server. Please check your network "
			+ "connection and try again.";

	/**
	 * This is the entry point method for the LifeBudget application.
	 * Contains the logic to initialize the application event bus as well
	 * as register all events and trigger the event to load the application.
	 */
	public void onModuleLoad() {
	
	    GXT.setDefaultTheme(Slate.SLATE, true);

	    Dispatcher dispatcher = Dispatcher.get();
	    dispatcher.addController(new AppController());
	    dispatcher.addController(new TabController());
	    dispatcher.addController(new TransactionJournalController());
	    dispatcher.addController(new CategoriesController());
	    dispatcher.addController(new OverviewController());
	    dispatcher.addController(new PaycheckCalculatorController());
	    

		Dispatcher.get().dispatch(AppEvents.Login);
		GXT.hideLoadingPanel("loading");
	    
	}

}
